//
// Created by Scave on 2023/11/8.
//

#ifndef RIDER3D_SCENERENDERER_H
#define RIDER3D_SCENERENDERER_H

#include "Define.h"
#include "render/config/RenderConfig.h"
#include "render/context/RenderContext.h"
#include "render/Renderer.h"
#include "component/Supposition.h"
#include "component/InternalComponent.h"
#include "Scene.h"

NS_RIDER_BEGIN

    class RiderEngine;

    class SceneRenderer {
        friend RiderEngine;
    public:
        explicit SceneRenderer(const RenderConfig& config);

        ~SceneRenderer();

        void SetScene(Scene* scene);

        /// OffScreen render, return the texture id after rendering
        /// \return Texture ID
        TEXTURE_ID_TYPE Render();

    private:
        /// Configuration for rendering
        RenderConfig render_config_;
        /// Context for rendering
        SMART_PTR<RenderContext> context_;
        SMART_PTR<MeshRenderer> renderer_mesh_;
        SMART_PTR<SpriteRenderer> renderer_sprite_;
        SMART_PTR<CanvasRenderer> renderer_canvas_;

        void RenderLayer(LayerMask mask, LayerRenderNodes& layer_nodes);
    };

NS_RIDER_END

#endif //RIDER3D_SCENERENDERER_H
